//#include "stdafx.h"
#include "CalcMem.h"

#ifdef _DEBUG
void OnMemOut_MS()
{
	//OutputDebugString(L"\nMEM OUT");
}
#endif

int _FourByteAlign(unsigned int unSize)
{
	return (int)((unSize + 3)&(~0x00000003));
}

void _CopyCalcMem(unsigned char *pDest, unsigned char *pSrc, int nMemSize)
{
	unsigned char *pEOF = pDest + nMemSize;
	unsigned char *pNext = pDest + 4;
	while (pNext <= pEOF)
	{
		*((unsigned int*)pDest) = *((unsigned int*)pSrc);
		pDest = pNext;
		pNext += 4;
		pSrc += 4;
	}
	while (pDest < pEOF)
	{
		*pDest = *pSrc;
		pDest++;
		pSrc++;
	}
}

int _GetCalcMemUse(MS_DATA * pLib)
{
	return pLib->nMemSize - ((unsigned int)pLib->pMemEp - (unsigned int)pLib->pMemSp);
}
